package com.tech.cloudapp.model;

import lombok.Data;

@Data
public class CommonResponseDO<T> {

    private int code;
    private String msg;
    private T data;

    public static CommonResponseDO builder(int code,String message)
    {
        CommonResponseDO resp = new CommonResponseDO();
        resp.setCode(code);
        resp.setMsg(message);
        return  resp;
    }


    public static <T>CommonResponseDO success(T data)
    {
        CommonResponseDO resp = new CommonResponseDO();
        resp.setCode(200);
        resp.setData(data);
        return  resp;
    }


    public static <T>CommonResponseDO fail(String code,String message)
    {
        CommonResponseDO resp = new CommonResponseDO();
        resp.setCode(500);
        resp.setMsg(message);
        return  resp;
    }

    public static <T>CommonResponseDO success()
    {
        CommonResponseDO resp = new CommonResponseDO();
        resp.setCode(200);
        resp.setMsg("执行成功");
        return  resp;
    }

}
